<?php
include DOCMENT_ROOT.'/framwork/model.class.php';
class adminModel extends model{
    public function __construct() {
        parent::connectMysqlDB("student");
    }
    public function checkField($where){
        if($where==""){
            return false;
        }
        $sql="select * from admin where {$where}";
        $arr= $this->mysql->select($sql);
        if($arr==null){
            return true;
        }else{
            return false;
        }
    }
     public function addAdmin($name,$pwd,$tel){
        $pwd=md5($pwd); 
        $date=date("Y-m-d h:i:s");
        $sql="insert into admin(name,pwd,tel,add_time,update_time) values('$name','$pwd','$tel','$date','$date')";
        $result=$this->mysql->add($sql);
        return $result;
    }
     public function checkLogin($name,$pwd){
        $pwd=md5($pwd); 
        $sql="select * from admin where name='$name' and pwd='$pwd'";
        $result=$this->mysql->select1($sql);
        return $result;
     }   
     public function adminList() {
        $sql="select * from admin";
        $arr= $this->mysql->select($sql);
        return $arr;
    }  
    public function selectAdmin($id) {
        $sql="select * from admin where id=$id";
        $arr= $this->mysql->select1($sql);
        return $arr;
    }
     public function update1Admin($name,$pwd,$tel,$id){
        $pwd = md5($pwd);
        $date=date("Y-m-d h:i:s");
        $mysql="update admin set pwd='$pwd',name='$name',update_time='$date',tel='$tel where id=$id";
        $result1= $this->mysql->update($mysql); 
        return $result1; 
     }
      public function updateAdmin($name,$tel,$id){
        $date=date("Y-m-d h:i:s");
        $sql="update admin set name='$name',update_time='$date',tel='$tel' where id=$id";
        $result= $this->mysql->update($sql);
        return $result;
      }
    public function deleteAdmin($id) {
        $sql="delete from admin where id = $id ";
        $result= $this->mysql->delete($sql);
        return $result;
    }

//..........
      public function articleList() {
        $sql="select * from article";
        $arr= $this->mysql->select($sql);
        return $arr;
    } 
    public function deleteArticle($id) {
        $sql="delete from article where id = $id ";
        $result= $this->mysql->delete($sql);
        return $result;
    } 
//..........
    public function user1List() {
        $sql="select * from user1";
        $arr= $this->mysql->select($sql);
        return $arr;
    } 
    public function deleteUser1($id) {
        $sql="delete from user1 where id = $id ";
        $result= $this->mysql->delete($sql);
        return $result;
    } 
}



